package com.db.client.demo;

import java.io.IOException;
import java.net.InetAddress;
import java.util.Arrays;

import com.db.client.gui.GuiControler;

public class DemoClient {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		int port = 40000;
		int index = Arrays.binarySearch(args, "-port"); 
		if (index >= 0 && index < args.length - 1) {
			try {
				port = Integer.valueOf(args[index + 1]);
			} catch (NumberFormatException exception) {
				port = 40000;
			}
		}
		InetAddress address = InetAddress.getLocalHost();
		index = Arrays.binarySearch(args, "-address"); 
		if (index >= 0 && index < args.length - 1) {
			try {
				address = InetAddress.getByName(args[index + 1]);
			} catch (NumberFormatException exception) {
				address = InetAddress.getLocalHost();
			}
		}
		GuiControler controler = new GuiControler(address, port);
		controler.runGui();
	}

}
